extension ListExpend<E> on List<E> {
  List<E> addOrUpdataWhereSame(List<E> list, bool Function(E, E) compare) {
    List<E> dataSource = this;
    if (dataSource.isEmpty) {
      dataSource.addAll(list);
    } else {
      for (int i = 0; i < dataSource.length; i++) {
        for (var element in list) {
          bool result = compare(dataSource[i], element);
          if (result) {
            dataSource[i] = element;
          } else {
            dataSource.add(element);
          }
        }
      }
    }
    return dataSource;
  }
}
